﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jayden.Dll.PathFinding;
using Jayden.Dll.Navigation.Core;

namespace Jayden.Dll.Navigation
{
	public class ShortestPathFinder : AStarPathFinder
	{
		protected override bool IsAccessible(PathInformation path) { return true; }

		protected override double EstimatedMovementCost(PathNode node, PathNodeCondition condition)
		{
			if (condition is PathNodeTarget)
			{
				PathNodeTarget target = condition as PathNodeTarget;
				if (node is Coordinate && target.Target is Coordinate)
				{
					Coordinate c1, c2;
					c1 = node as Coordinate;
					c2 = target.Target as Coordinate;
					return Coordinate.Distance(c1, c2);
				}
			}
			return 0;
		}

		protected override double MovementCost(PathInformation path)
		{
			if (path is Way)
				return (path as Way).Distance;
			if (path.Start is Coordinate && path.End is Coordinate)
			{
				Coordinate c1, c2;
				c1 = path.Start as Coordinate;
				c2 = path.End as Coordinate;
				return Coordinate.Distance(c1, c2);
			}
			throw new Exception("Unsupported PathNode.");
		}
	}
}
